package com.zmm.zebulon.module.member.biz.dal.mysql.tag;

import com.zmm.zebulon.common.pojo.PageResult;
import com.zmm.zebulon.module.member.biz.controller.admin.tag.vo.MemberTagPageReqVO;
import com.zmm.zebulon.module.member.biz.dal.dataobject.tag.MemberTagDO;
import com.zmm.zebulon.starter.mybatis.mybatis.core.mapper.BaseMapperX;
import com.zmm.zebulon.starter.mybatis.mybatis.core.query.LambdaQueryWrapperX;
import org.apache.ibatis.annotations.Mapper;

/**
 * description: 会员标签 Mapper
 *
 * @author zebulon
 * package com.zmm.zebulon.module.member.biz.dal.mysql.tag
 * name: MemberTagMapper
 * date 2024/1/10 20:59
 */
@Mapper
public interface MemberTagMapper extends BaseMapperX<MemberTagDO> {

    default PageResult<MemberTagDO> selectPage(MemberTagPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MemberTagDO>()
                .likeIfPresent(MemberTagDO::getName, reqVO.getName())
                .betweenIfPresent(MemberTagDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(MemberTagDO::getId));
    }

    default MemberTagDO selectByName(String name) {
        return selectOne(MemberTagDO::getName, name);
    }
}
